<?php

namespace App\Containers\AppSection\Questionnaire\UI\API\Transformers;

use App\Containers\AppSection\Questionnaire\Models\Form;
use App\Containers\AppSection\Type\UI\API\Transformers\TypeTransformer;
use App\Ship\Parents\Transformers\Transformer;
use League\Fractal\Resource\Item;

class FormTransformer extends Transformer
{
    protected array $defaultIncludes = [
        'legal_form'
    ];

    /**
     * @var  array
     */
    protected array $availableIncludes = [

    ];

    public function transform(Form $t): array
    {
        return [
            'object' => $t->getResourceKey(),
            'include' => $this->getAvailableIncludes(),
            'id' => $t->getHashedKey(),
            'legal_form' => $t->legal_form_type,
            'question' => $t->question,
            'description' => $t->description,
            'required' => $t->required,
            'order' => $t->order,
            'some' => $t->some,

        ];
    }

    public function includeLegalForm(Form $t): Item
    {
        return $this->item($t->legal_form, new TypeTransformer);
    }
}
